package com.liujing.tacticspatten;

/**
 * @program: DesignPattenDemo
 * @description: 满减金额
 * @author: liujing
 * @create: 2019-11-22 11:03
 **/
public class CashReturn extends CashSuper {
    /**
     * 满减条件
     */
    private double moneyCondition = 0d;
    /**
     * 满减返额
     */
    private double moneyReturn = 0d;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double money) {
        double result = money;
        if (money >= moneyCondition) {
            result = money - Math.floor(money / moneyCondition) * moneyReturn;
        }
        return result;
    }
}
